{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 读取并筛选第一个表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>股票代码</th>\n",
       "      <th>名称</th>\n",
       "      <th>高数</th>\n",
       "      <th>实际2</th>\n",
       "      <th>Unnamed: 5</th>\n",
       "      <th>Unnamed: 6</th>\n",
       "      <th>Unnamed: 7</th>\n",
       "      <th>Unnamed: 8</th>\n",
       "      <th>Unnamed: 9</th>\n",
       "      <th>Unnamed: 10</th>\n",
       "      <th>Unnamed: 11</th>\n",
       "      <th>Unnamed: 12</th>\n",
       "      <th>Unnamed: 13</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2984</td>\n",
       "      <td>森麒麟</td>\n",
       "      <td>0.010</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>603915</td>\n",
       "      <td>国茂股份</td>\n",
       "      <td>0.020</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>2539</td>\n",
       "      <td>云图控股</td>\n",
       "      <td>0.001</td>\n",
       "      <td>4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>300894</td>\n",
       "      <td>火星人</td>\n",
       "      <td>0.001</td>\n",
       "      <td>5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>603599</td>\n",
       "      <td>广信股份</td>\n",
       "      <td>0.001</td>\n",
       "      <td>6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0    股票代码     名称     高数  实际2  Unnamed: 5  Unnamed: 6  Unnamed: 7  \\\n",
       "0           1    2984    森麒麟  0.010    2         NaN         NaN         NaN   \n",
       "1           2  603915   国茂股份  0.020    3         NaN         NaN         NaN   \n",
       "2           3    2539   云图控股  0.001    4         NaN         NaN         NaN   \n",
       "3           4  300894    火星人  0.001    5         NaN         NaN         NaN   \n",
       "4           5  603599   广信股份  0.001    6         NaN         NaN         NaN   \n",
       "\n",
       "   Unnamed: 8  Unnamed: 9  Unnamed: 10  Unnamed: 11  Unnamed: 12 Unnamed: 13  \n",
       "0         NaN         NaN          NaN          NaN          NaN         NaN  \n",
       "1         NaN         NaN          NaN          NaN          NaN         NaN  \n",
       "2         NaN         NaN          NaN          NaN          NaN         NaN  \n",
       "3         NaN         NaN          NaN          NaN          NaN         NaN  \n",
       "4         NaN         NaN          NaN          NaN          NaN         NaN  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1 = pd.read_excel(\"第一个表.xlsx\")\n",
    "df1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "股票代码      int64\n",
       "高数      float64\n",
       "实际2       int64\n",
       "dtype: object"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>股票代码</th>\n",
       "      <th>高数</th>\n",
       "      <th>实际2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2984</td>\n",
       "      <td>0.010</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>603915</td>\n",
       "      <td>0.020</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2539</td>\n",
       "      <td>0.001</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>300894</td>\n",
       "      <td>0.001</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>603599</td>\n",
       "      <td>0.001</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1262</th>\n",
       "      <td>2060</td>\n",
       "      <td>0.001</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1263</th>\n",
       "      <td>2533</td>\n",
       "      <td>0.001</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1264</th>\n",
       "      <td>600808</td>\n",
       "      <td>0.001</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1265</th>\n",
       "      <td>600021</td>\n",
       "      <td>0.001</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1266</th>\n",
       "      <td>601158</td>\n",
       "      <td>0.001</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1267 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        股票代码     高数  实际2\n",
       "0       2984  0.010    2\n",
       "1     603915  0.020    3\n",
       "2       2539  0.001    4\n",
       "3     300894  0.001    5\n",
       "4     603599  0.001    6\n",
       "...      ...    ...  ...\n",
       "1262    2060  0.001    2\n",
       "1263    2533  0.001    2\n",
       "1264  600808  0.001    2\n",
       "1265  600021  0.001    2\n",
       "1266  601158  0.001    2\n",
       "\n",
       "[1267 rows x 3 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 删除无用列\n",
    "df1 = df1[[\"股票代码\", \"高数\", \"实际2\"]].copy()\n",
    "df1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 读取并处理第二个表"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "主要得用到transpose做横竖转换，方便处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>10</th>\n",
       "      <th>11</th>\n",
       "      <th>12</th>\n",
       "      <th>13</th>\n",
       "      <th>14</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>股票代码</td>\n",
       "      <td>002984</td>\n",
       "      <td>603915</td>\n",
       "      <td>002539</td>\n",
       "      <td>300894</td>\n",
       "      <td>603599</td>\n",
       "      <td>600346</td>\n",
       "      <td>600989</td>\n",
       "      <td>603218</td>\n",
       "      <td>603833</td>\n",
       "      <td>603882</td>\n",
       "      <td>002553</td>\n",
       "      <td>603489</td>\n",
       "      <td>603456</td>\n",
       "      <td>605376</td>\n",
       "      <td>300142</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>股票名称</td>\n",
       "      <td>森麒麟</td>\n",
       "      <td>国茂股份</td>\n",
       "      <td>云图控股</td>\n",
       "      <td>火星人</td>\n",
       "      <td>广信股份</td>\n",
       "      <td>恒力石化</td>\n",
       "      <td>宝丰能源</td>\n",
       "      <td>日月股份</td>\n",
       "      <td>欧派家居</td>\n",
       "      <td>金域医学</td>\n",
       "      <td>南方轴承</td>\n",
       "      <td>八方股份</td>\n",
       "      <td>九洲药业</td>\n",
       "      <td>博迁新材</td>\n",
       "      <td>沃森生物</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>行业</td>\n",
       "      <td>汽车配件</td>\n",
       "      <td>机械基件</td>\n",
       "      <td>农药化肥</td>\n",
       "      <td>家用电器</td>\n",
       "      <td>农药化肥</td>\n",
       "      <td>化纤</td>\n",
       "      <td>化工原料</td>\n",
       "      <td>工程机械</td>\n",
       "      <td>家居用品</td>\n",
       "      <td>医疗保健</td>\n",
       "      <td>汽车配件</td>\n",
       "      <td>电气设备</td>\n",
       "      <td>化学制药</td>\n",
       "      <td>小金属</td>\n",
       "      <td>生物制药</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>天数</td>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>23</td>\n",
       "      <td>24</td>\n",
       "      <td>20</td>\n",
       "      <td>25</td>\n",
       "      <td>20</td>\n",
       "      <td>27</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>20</td>\n",
       "      <td>24</td>\n",
       "      <td>20</td>\n",
       "      <td>20</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>正负</td>\n",
       "      <td>0.7</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.65</td>\n",
       "      <td>0.45</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.65</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.4</td>\n",
       "      <td>0.4</td>\n",
       "      <td>0.55</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Unnamed: 0       0       1       2       3       4       5       6       7  \\\n",
       "0       股票代码  002984  603915  002539  300894  603599  600346  600989  603218   \n",
       "1       股票名称     森麒麟    国茂股份    云图控股     火星人    广信股份    恒力石化    宝丰能源    日月股份   \n",
       "2         行业    汽车配件    机械基件    农药化肥    家用电器    农药化肥      化纤    化工原料    工程机械   \n",
       "3         天数      21      22      23      24      20      25      20      27   \n",
       "4         正负     0.7     0.6    0.65    0.45     0.5    0.65     0.6     0.5   \n",
       "\n",
       "        8       9      10      11      12      13      14  \n",
       "0  603833  603882  002553  603489  603456  605376  300142  \n",
       "1    欧派家居    金域医学    南方轴承    八方股份    九洲药业    博迁新材    沃森生物  \n",
       "2    家居用品    医疗保健    汽车配件    电气设备    化学制药     小金属    生物制药  \n",
       "3      20      28      20      24      20      20      20  \n",
       "4     0.5     0.4     0.4    0.55     0.5     0.5     0.6  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2 = pd.read_excel(\"第二个表.xlsx\")\n",
    "df2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>10</th>\n",
       "      <th>11</th>\n",
       "      <th>12</th>\n",
       "      <th>13</th>\n",
       "      <th>14</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>股票代码</th>\n",
       "      <td>002984</td>\n",
       "      <td>603915</td>\n",
       "      <td>002539</td>\n",
       "      <td>300894</td>\n",
       "      <td>603599</td>\n",
       "      <td>600346</td>\n",
       "      <td>600989</td>\n",
       "      <td>603218</td>\n",
       "      <td>603833</td>\n",
       "      <td>603882</td>\n",
       "      <td>002553</td>\n",
       "      <td>603489</td>\n",
       "      <td>603456</td>\n",
       "      <td>605376</td>\n",
       "      <td>300142</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票名称</th>\n",
       "      <td>森麒麟</td>\n",
       "      <td>国茂股份</td>\n",
       "      <td>云图控股</td>\n",
       "      <td>火星人</td>\n",
       "      <td>广信股份</td>\n",
       "      <td>恒力石化</td>\n",
       "      <td>宝丰能源</td>\n",
       "      <td>日月股份</td>\n",
       "      <td>欧派家居</td>\n",
       "      <td>金域医学</td>\n",
       "      <td>南方轴承</td>\n",
       "      <td>八方股份</td>\n",
       "      <td>九洲药业</td>\n",
       "      <td>博迁新材</td>\n",
       "      <td>沃森生物</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>行业</th>\n",
       "      <td>汽车配件</td>\n",
       "      <td>机械基件</td>\n",
       "      <td>农药化肥</td>\n",
       "      <td>家用电器</td>\n",
       "      <td>农药化肥</td>\n",
       "      <td>化纤</td>\n",
       "      <td>化工原料</td>\n",
       "      <td>工程机械</td>\n",
       "      <td>家居用品</td>\n",
       "      <td>医疗保健</td>\n",
       "      <td>汽车配件</td>\n",
       "      <td>电气设备</td>\n",
       "      <td>化学制药</td>\n",
       "      <td>小金属</td>\n",
       "      <td>生物制药</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>天数</th>\n",
       "      <td>21</td>\n",
       "      <td>22</td>\n",
       "      <td>23</td>\n",
       "      <td>24</td>\n",
       "      <td>20</td>\n",
       "      <td>25</td>\n",
       "      <td>20</td>\n",
       "      <td>27</td>\n",
       "      <td>20</td>\n",
       "      <td>28</td>\n",
       "      <td>20</td>\n",
       "      <td>24</td>\n",
       "      <td>20</td>\n",
       "      <td>20</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>正负</th>\n",
       "      <td>0.7</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.65</td>\n",
       "      <td>0.45</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.65</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.4</td>\n",
       "      <td>0.4</td>\n",
       "      <td>0.55</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                0       1       2       3       4       5       6       7   \\\n",
       "Unnamed: 0                                                                   \n",
       "股票代码        002984  603915  002539  300894  603599  600346  600989  603218   \n",
       "股票名称           森麒麟    国茂股份    云图控股     火星人    广信股份    恒力石化    宝丰能源    日月股份   \n",
       "行业            汽车配件    机械基件    农药化肥    家用电器    农药化肥      化纤    化工原料    工程机械   \n",
       "天数              21      22      23      24      20      25      20      27   \n",
       "正负             0.7     0.6    0.65    0.45     0.5    0.65     0.6     0.5   \n",
       "\n",
       "                8       9       10      11      12      13      14  \n",
       "Unnamed: 0                                                          \n",
       "股票代码        603833  603882  002553  603489  603456  605376  300142  \n",
       "股票名称          欧派家居    金域医学    南方轴承    八方股份    九洲药业    博迁新材    沃森生物  \n",
       "行业            家居用品    医疗保健    汽车配件    电气设备    化学制药     小金属    生物制药  \n",
       "天数              20      28      20      24      20      20      20  \n",
       "正负             0.5     0.4     0.4    0.55     0.5     0.5     0.6  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.set_index(\"Unnamed: 0\", inplace=True)\n",
    "df2.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>股票代码</th>\n",
       "      <th>股票名称</th>\n",
       "      <th>行业</th>\n",
       "      <th>天数</th>\n",
       "      <th>正负</th>\n",
       "      <th>看好</th>\n",
       "      <th>出手</th>\n",
       "      <th>结果</th>\n",
       "      <th>20210210</th>\n",
       "      <th>20210209</th>\n",
       "      <th>...</th>\n",
       "      <th>20210127</th>\n",
       "      <th>20210126</th>\n",
       "      <th>20210125</th>\n",
       "      <th>20210122</th>\n",
       "      <th>20210121</th>\n",
       "      <th>20210120</th>\n",
       "      <th>20210119</th>\n",
       "      <th>20210118</th>\n",
       "      <th>20210115</th>\n",
       "      <th>20210114</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>002984</td>\n",
       "      <td>森麒麟</td>\n",
       "      <td>汽车配件</td>\n",
       "      <td>21</td>\n",
       "      <td>0.7</td>\n",
       "      <td>0.95</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.15</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>603915</td>\n",
       "      <td>国茂股份</td>\n",
       "      <td>机械基件</td>\n",
       "      <td>22</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.4</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>...</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>002539</td>\n",
       "      <td>云图控股</td>\n",
       "      <td>农药化肥</td>\n",
       "      <td>23</td>\n",
       "      <td>0.65</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.1</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>...</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>300894</td>\n",
       "      <td>火星人</td>\n",
       "      <td>家用电器</td>\n",
       "      <td>24</td>\n",
       "      <td>0.45</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.1</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>...</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>603599</td>\n",
       "      <td>广信股份</td>\n",
       "      <td>农药化肥</td>\n",
       "      <td>20</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.95</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.05</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>...</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>600346</td>\n",
       "      <td>恒力石化</td>\n",
       "      <td>化纤</td>\n",
       "      <td>25</td>\n",
       "      <td>0.65</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.15</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>...</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>600989</td>\n",
       "      <td>宝丰能源</td>\n",
       "      <td>化工原料</td>\n",
       "      <td>20</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.3</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>...</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>603218</td>\n",
       "      <td>日月股份</td>\n",
       "      <td>工程机械</td>\n",
       "      <td>27</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.1</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>...</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>603833</td>\n",
       "      <td>欧派家居</td>\n",
       "      <td>家居用品</td>\n",
       "      <td>20</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.1</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>...</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>603882</td>\n",
       "      <td>金域医学</td>\n",
       "      <td>医疗保健</td>\n",
       "      <td>28</td>\n",
       "      <td>0.4</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.4</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>...</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>002553</td>\n",
       "      <td>南方轴承</td>\n",
       "      <td>汽车配件</td>\n",
       "      <td>20</td>\n",
       "      <td>0.4</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.2</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>...</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>603489</td>\n",
       "      <td>八方股份</td>\n",
       "      <td>电气设备</td>\n",
       "      <td>24</td>\n",
       "      <td>0.55</td>\n",
       "      <td>0.95</td>\n",
       "      <td>0.8</td>\n",
       "      <td>0.3</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>...</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>603456</td>\n",
       "      <td>九洲药业</td>\n",
       "      <td>化学制药</td>\n",
       "      <td>20</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.8</td>\n",
       "      <td>0.25</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>...</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>605376</td>\n",
       "      <td>博迁新材</td>\n",
       "      <td>小金属</td>\n",
       "      <td>20</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.8</td>\n",
       "      <td>0.5</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>...</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>300142</td>\n",
       "      <td>沃森生物</td>\n",
       "      <td>生物制药</td>\n",
       "      <td>20</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.8</td>\n",
       "      <td>0.1</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>...</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>15 rows × 28 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "Unnamed: 0    股票代码  股票名称    行业  天数    正负    看好    出手    结果 20210210 20210209  \\\n",
       "0           002984   森麒麟  汽车配件  21   0.7  0.95   0.9  0.15        2        2   \n",
       "1           603915  国茂股份  机械基件  22   0.6   0.9   0.9   0.4        3        3   \n",
       "2           002539  云图控股  农药化肥  23  0.65   0.9   0.9   0.1        4        4   \n",
       "3           300894   火星人  家用电器  24  0.45     0   0.9   0.1        5        5   \n",
       "4           603599  广信股份  农药化肥  20   0.5  0.95  0.85  0.05        6        6   \n",
       "5           600346  恒力石化    化纤  25  0.65   0.9  0.85  0.15        7        7   \n",
       "6           600989  宝丰能源  化工原料  20   0.6   0.9  0.85   0.3        8        8   \n",
       "7           603218  日月股份  工程机械  27   0.5   0.9  0.85   0.1        9        9   \n",
       "8           603833  欧派家居  家居用品  20   0.5   0.9  0.85   0.1       10       10   \n",
       "9           603882  金域医学  医疗保健  28   0.4   0.9  0.85   0.4       11       11   \n",
       "10          002553  南方轴承  汽车配件  20   0.4  0.85  0.85   0.2       12       12   \n",
       "11          603489  八方股份  电气设备  24  0.55  0.95   0.8   0.3       13       13   \n",
       "12          603456  九洲药业  化学制药  20   0.5   0.9   0.8  0.25       14       14   \n",
       "13          605376  博迁新材   小金属  20   0.5   0.9   0.8   0.5       15       15   \n",
       "14          300142  沃森生物  生物制药  20   0.6   0.9   0.8   0.1       16       16   \n",
       "\n",
       "Unnamed: 0  ... 20210127 20210126 20210125 20210122 20210121 20210120  \\\n",
       "0           ...        2        2        2        2        2        2   \n",
       "1           ...        3        3        3        3        3        3   \n",
       "2           ...        4        4        4        4        4        4   \n",
       "3           ...        5        5        5        5        5        5   \n",
       "4           ...        6        6        6        6        6        6   \n",
       "5           ...        7        7        7        7        7        7   \n",
       "6           ...        8        8        8        8        8        8   \n",
       "7           ...        9        9        9        9        9        9   \n",
       "8           ...       10       10       10       10       10       10   \n",
       "9           ...       11       11       11       11       11       11   \n",
       "10          ...       12       12       12       12       12       12   \n",
       "11          ...       13       13       13       13       13       13   \n",
       "12          ...       14       14       14       14       14       14   \n",
       "13          ...       15       15       15       15       15       15   \n",
       "14          ...       16       16       16       16       16       16   \n",
       "\n",
       "Unnamed: 0 20210119 20210118 20210115 20210114  \n",
       "0                 2        2        2        2  \n",
       "1                 3        3        3        3  \n",
       "2                 4        4        4        4  \n",
       "3                 5        5        5        5  \n",
       "4                 6        6        6        6  \n",
       "5                 7        7        7        7  \n",
       "6                 8        8        8        8  \n",
       "7                 9        9        9        9  \n",
       "8                10       10       10       10  \n",
       "9                11       11       11       11  \n",
       "10               12       12       12       12  \n",
       "11               13       13       13       13  \n",
       "12               14       14       14       14  \n",
       "13               15       15       15       15  \n",
       "14               16       16       16       16  \n",
       "\n",
       "[15 rows x 28 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2 = df2.transpose()\n",
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Unnamed: 0\n",
       "股票代码        object\n",
       "股票名称        object\n",
       "行业          object\n",
       "天数          object\n",
       "正负          object\n",
       "看好          object\n",
       "出手          object\n",
       "结果          object\n",
       "20210210    object\n",
       "20210209    object\n",
       "20210208    object\n",
       "20210205    object\n",
       "20210204    object\n",
       "20210203    object\n",
       "20210202    object\n",
       "20210201    object\n",
       "20210129    object\n",
       "20210128    object\n",
       "20210127    object\n",
       "20210126    object\n",
       "20210125    object\n",
       "20210122    object\n",
       "20210121    object\n",
       "20210120    object\n",
       "20210119    object\n",
       "20210118    object\n",
       "20210115    object\n",
       "20210114    object\n",
       "dtype: object"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>股票代码</th>\n",
       "      <th>股票名称</th>\n",
       "      <th>行业</th>\n",
       "      <th>天数</th>\n",
       "      <th>正负</th>\n",
       "      <th>看好</th>\n",
       "      <th>出手</th>\n",
       "      <th>结果</th>\n",
       "      <th>20210210</th>\n",
       "      <th>20210209</th>\n",
       "      <th>...</th>\n",
       "      <th>20210127</th>\n",
       "      <th>20210126</th>\n",
       "      <th>20210125</th>\n",
       "      <th>20210122</th>\n",
       "      <th>20210121</th>\n",
       "      <th>20210120</th>\n",
       "      <th>20210119</th>\n",
       "      <th>20210118</th>\n",
       "      <th>20210115</th>\n",
       "      <th>20210114</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2984</td>\n",
       "      <td>森麒麟</td>\n",
       "      <td>汽车配件</td>\n",
       "      <td>21</td>\n",
       "      <td>0.7</td>\n",
       "      <td>0.95</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.15</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>603915</td>\n",
       "      <td>国茂股份</td>\n",
       "      <td>机械基件</td>\n",
       "      <td>22</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.4</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>...</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2539</td>\n",
       "      <td>云图控股</td>\n",
       "      <td>农药化肥</td>\n",
       "      <td>23</td>\n",
       "      <td>0.65</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.1</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>...</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>300894</td>\n",
       "      <td>火星人</td>\n",
       "      <td>家用电器</td>\n",
       "      <td>24</td>\n",
       "      <td>0.45</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.1</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>...</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>603599</td>\n",
       "      <td>广信股份</td>\n",
       "      <td>农药化肥</td>\n",
       "      <td>20</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.95</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.05</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>...</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>600346</td>\n",
       "      <td>恒力石化</td>\n",
       "      <td>化纤</td>\n",
       "      <td>25</td>\n",
       "      <td>0.65</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.15</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>...</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>600989</td>\n",
       "      <td>宝丰能源</td>\n",
       "      <td>化工原料</td>\n",
       "      <td>20</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.3</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>...</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>603218</td>\n",
       "      <td>日月股份</td>\n",
       "      <td>工程机械</td>\n",
       "      <td>27</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.1</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>...</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>603833</td>\n",
       "      <td>欧派家居</td>\n",
       "      <td>家居用品</td>\n",
       "      <td>20</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.1</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>...</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>603882</td>\n",
       "      <td>金域医学</td>\n",
       "      <td>医疗保健</td>\n",
       "      <td>28</td>\n",
       "      <td>0.4</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.4</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>...</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2553</td>\n",
       "      <td>南方轴承</td>\n",
       "      <td>汽车配件</td>\n",
       "      <td>20</td>\n",
       "      <td>0.4</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.2</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>...</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>603489</td>\n",
       "      <td>八方股份</td>\n",
       "      <td>电气设备</td>\n",
       "      <td>24</td>\n",
       "      <td>0.55</td>\n",
       "      <td>0.95</td>\n",
       "      <td>0.8</td>\n",
       "      <td>0.3</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>...</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>603456</td>\n",
       "      <td>九洲药业</td>\n",
       "      <td>化学制药</td>\n",
       "      <td>20</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.8</td>\n",
       "      <td>0.25</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>...</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>605376</td>\n",
       "      <td>博迁新材</td>\n",
       "      <td>小金属</td>\n",
       "      <td>20</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.8</td>\n",
       "      <td>0.5</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>...</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>300142</td>\n",
       "      <td>沃森生物</td>\n",
       "      <td>生物制药</td>\n",
       "      <td>20</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.8</td>\n",
       "      <td>0.1</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>...</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>15 rows × 28 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "Unnamed: 0    股票代码  股票名称    行业  天数    正负    看好    出手    结果 20210210 20210209  \\\n",
       "0             2984   森麒麟  汽车配件  21   0.7  0.95   0.9  0.15        2        2   \n",
       "1           603915  国茂股份  机械基件  22   0.6   0.9   0.9   0.4        3        3   \n",
       "2             2539  云图控股  农药化肥  23  0.65   0.9   0.9   0.1        4        4   \n",
       "3           300894   火星人  家用电器  24  0.45     0   0.9   0.1        5        5   \n",
       "4           603599  广信股份  农药化肥  20   0.5  0.95  0.85  0.05        6        6   \n",
       "5           600346  恒力石化    化纤  25  0.65   0.9  0.85  0.15        7        7   \n",
       "6           600989  宝丰能源  化工原料  20   0.6   0.9  0.85   0.3        8        8   \n",
       "7           603218  日月股份  工程机械  27   0.5   0.9  0.85   0.1        9        9   \n",
       "8           603833  欧派家居  家居用品  20   0.5   0.9  0.85   0.1       10       10   \n",
       "9           603882  金域医学  医疗保健  28   0.4   0.9  0.85   0.4       11       11   \n",
       "10            2553  南方轴承  汽车配件  20   0.4  0.85  0.85   0.2       12       12   \n",
       "11          603489  八方股份  电气设备  24  0.55  0.95   0.8   0.3       13       13   \n",
       "12          603456  九洲药业  化学制药  20   0.5   0.9   0.8  0.25       14       14   \n",
       "13          605376  博迁新材   小金属  20   0.5   0.9   0.8   0.5       15       15   \n",
       "14          300142  沃森生物  生物制药  20   0.6   0.9   0.8   0.1       16       16   \n",
       "\n",
       "Unnamed: 0  ... 20210127 20210126 20210125 20210122 20210121 20210120  \\\n",
       "0           ...        2        2        2        2        2        2   \n",
       "1           ...        3        3        3        3        3        3   \n",
       "2           ...        4        4        4        4        4        4   \n",
       "3           ...        5        5        5        5        5        5   \n",
       "4           ...        6        6        6        6        6        6   \n",
       "5           ...        7        7        7        7        7        7   \n",
       "6           ...        8        8        8        8        8        8   \n",
       "7           ...        9        9        9        9        9        9   \n",
       "8           ...       10       10       10       10       10       10   \n",
       "9           ...       11       11       11       11       11       11   \n",
       "10          ...       12       12       12       12       12       12   \n",
       "11          ...       13       13       13       13       13       13   \n",
       "12          ...       14       14       14       14       14       14   \n",
       "13          ...       15       15       15       15       15       15   \n",
       "14          ...       16       16       16       16       16       16   \n",
       "\n",
       "Unnamed: 0 20210119 20210118 20210115 20210114  \n",
       "0                 2        2        2        2  \n",
       "1                 3        3        3        3  \n",
       "2                 4        4        4        4  \n",
       "3                 5        5        5        5  \n",
       "4                 6        6        6        6  \n",
       "5                 7        7        7        7  \n",
       "6                 8        8        8        8  \n",
       "7                 9        9        9        9  \n",
       "8                10       10       10       10  \n",
       "9                11       11       11       11  \n",
       "10               12       12       12       12  \n",
       "11               13       13       13       13  \n",
       "12               14       14       14       14  \n",
       "13               15       15       15       15  \n",
       "14               16       16       16       16  \n",
       "\n",
       "[15 rows x 28 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 第一个表的股票代码是数字，这里第二个表也转换下；\n",
    "# 如果原始数据都是字符串或者数字，这里不需要转换\n",
    "df2[\"股票代码\"] = df2[\"股票代码\"].astype(int)\n",
    "df2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 数据合并"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>股票代码</th>\n",
       "      <th>股票名称</th>\n",
       "      <th>行业</th>\n",
       "      <th>天数</th>\n",
       "      <th>正负</th>\n",
       "      <th>看好</th>\n",
       "      <th>出手</th>\n",
       "      <th>结果</th>\n",
       "      <th>20210210</th>\n",
       "      <th>20210209</th>\n",
       "      <th>...</th>\n",
       "      <th>20210125</th>\n",
       "      <th>20210122</th>\n",
       "      <th>20210121</th>\n",
       "      <th>20210120</th>\n",
       "      <th>20210119</th>\n",
       "      <th>20210118</th>\n",
       "      <th>20210115</th>\n",
       "      <th>20210114</th>\n",
       "      <th>高数</th>\n",
       "      <th>实际2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2984</td>\n",
       "      <td>森麒麟</td>\n",
       "      <td>汽车配件</td>\n",
       "      <td>21</td>\n",
       "      <td>0.7</td>\n",
       "      <td>0.95</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.15</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>0.010</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>603915</td>\n",
       "      <td>国茂股份</td>\n",
       "      <td>机械基件</td>\n",
       "      <td>22</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.4</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>...</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>0.020</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2539</td>\n",
       "      <td>云图控股</td>\n",
       "      <td>农药化肥</td>\n",
       "      <td>23</td>\n",
       "      <td>0.65</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.1</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>...</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>0.001</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>300894</td>\n",
       "      <td>火星人</td>\n",
       "      <td>家用电器</td>\n",
       "      <td>24</td>\n",
       "      <td>0.45</td>\n",
       "      <td>0</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.1</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>...</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>0.001</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>603599</td>\n",
       "      <td>广信股份</td>\n",
       "      <td>农药化肥</td>\n",
       "      <td>20</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.95</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.05</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>...</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>6</td>\n",
       "      <td>0.001</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>600346</td>\n",
       "      <td>恒力石化</td>\n",
       "      <td>化纤</td>\n",
       "      <td>25</td>\n",
       "      <td>0.65</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.15</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>...</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>7</td>\n",
       "      <td>0.001</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>600989</td>\n",
       "      <td>宝丰能源</td>\n",
       "      <td>化工原料</td>\n",
       "      <td>20</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.3</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>...</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>0.001</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>603218</td>\n",
       "      <td>日月股份</td>\n",
       "      <td>工程机械</td>\n",
       "      <td>27</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.1</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>...</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>0.001</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>603833</td>\n",
       "      <td>欧派家居</td>\n",
       "      <td>家居用品</td>\n",
       "      <td>20</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.1</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>...</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>0.001</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>603882</td>\n",
       "      <td>金域医学</td>\n",
       "      <td>医疗保健</td>\n",
       "      <td>28</td>\n",
       "      <td>0.4</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.4</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>...</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>11</td>\n",
       "      <td>0.001</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2553</td>\n",
       "      <td>南方轴承</td>\n",
       "      <td>汽车配件</td>\n",
       "      <td>20</td>\n",
       "      <td>0.4</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.85</td>\n",
       "      <td>0.2</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>...</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>0.001</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>603489</td>\n",
       "      <td>八方股份</td>\n",
       "      <td>电气设备</td>\n",
       "      <td>24</td>\n",
       "      <td>0.55</td>\n",
       "      <td>0.95</td>\n",
       "      <td>0.8</td>\n",
       "      <td>0.3</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>...</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>13</td>\n",
       "      <td>0.001</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>603456</td>\n",
       "      <td>九洲药业</td>\n",
       "      <td>化学制药</td>\n",
       "      <td>20</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.8</td>\n",
       "      <td>0.25</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>...</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>14</td>\n",
       "      <td>0.001</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>605376</td>\n",
       "      <td>博迁新材</td>\n",
       "      <td>小金属</td>\n",
       "      <td>20</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.8</td>\n",
       "      <td>0.5</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>...</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>15</td>\n",
       "      <td>0.001</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>300142</td>\n",
       "      <td>沃森生物</td>\n",
       "      <td>生物制药</td>\n",
       "      <td>20</td>\n",
       "      <td>0.6</td>\n",
       "      <td>0.9</td>\n",
       "      <td>0.8</td>\n",
       "      <td>0.1</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>...</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>16</td>\n",
       "      <td>0.001</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>15 rows × 30 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      股票代码  股票名称    行业  天数    正负    看好    出手    结果 20210210 20210209  ...  \\\n",
       "0     2984   森麒麟  汽车配件  21   0.7  0.95   0.9  0.15        2        2  ...   \n",
       "1   603915  国茂股份  机械基件  22   0.6   0.9   0.9   0.4        3        3  ...   \n",
       "2     2539  云图控股  农药化肥  23  0.65   0.9   0.9   0.1        4        4  ...   \n",
       "3   300894   火星人  家用电器  24  0.45     0   0.9   0.1        5        5  ...   \n",
       "4   603599  广信股份  农药化肥  20   0.5  0.95  0.85  0.05        6        6  ...   \n",
       "5   600346  恒力石化    化纤  25  0.65   0.9  0.85  0.15        7        7  ...   \n",
       "6   600989  宝丰能源  化工原料  20   0.6   0.9  0.85   0.3        8        8  ...   \n",
       "7   603218  日月股份  工程机械  27   0.5   0.9  0.85   0.1        9        9  ...   \n",
       "8   603833  欧派家居  家居用品  20   0.5   0.9  0.85   0.1       10       10  ...   \n",
       "9   603882  金域医学  医疗保健  28   0.4   0.9  0.85   0.4       11       11  ...   \n",
       "10    2553  南方轴承  汽车配件  20   0.4  0.85  0.85   0.2       12       12  ...   \n",
       "11  603489  八方股份  电气设备  24  0.55  0.95   0.8   0.3       13       13  ...   \n",
       "12  603456  九洲药业  化学制药  20   0.5   0.9   0.8  0.25       14       14  ...   \n",
       "13  605376  博迁新材   小金属  20   0.5   0.9   0.8   0.5       15       15  ...   \n",
       "14  300142  沃森生物  生物制药  20   0.6   0.9   0.8   0.1       16       16  ...   \n",
       "\n",
       "   20210125 20210122 20210121 20210120 20210119 20210118 20210115 20210114  \\\n",
       "0         2        2        2        2        2        2        2        2   \n",
       "1         3        3        3        3        3        3        3        3   \n",
       "2         4        4        4        4        4        4        4        4   \n",
       "3         5        5        5        5        5        5        5        5   \n",
       "4         6        6        6        6        6        6        6        6   \n",
       "5         7        7        7        7        7        7        7        7   \n",
       "6         8        8        8        8        8        8        8        8   \n",
       "7         9        9        9        9        9        9        9        9   \n",
       "8        10       10       10       10       10       10       10       10   \n",
       "9        11       11       11       11       11       11       11       11   \n",
       "10       12       12       12       12       12       12       12       12   \n",
       "11       13       13       13       13       13       13       13       13   \n",
       "12       14       14       14       14       14       14       14       14   \n",
       "13       15       15       15       15       15       15       15       15   \n",
       "14       16       16       16       16       16       16       16       16   \n",
       "\n",
       "       高数 实际2  \n",
       "0   0.010   2  \n",
       "1   0.020   3  \n",
       "2   0.001   4  \n",
       "3   0.001   5  \n",
       "4   0.001   6  \n",
       "5   0.001   7  \n",
       "6   0.001   8  \n",
       "7   0.001   9  \n",
       "8   0.001  10  \n",
       "9   0.001  11  \n",
       "10  0.001  12  \n",
       "11  0.001  13  \n",
       "12  0.001  14  \n",
       "13  0.001  15  \n",
       "14  0.001  16  \n",
       "\n",
       "[15 rows x 30 columns]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_merge = pd.merge(left=df2, right=df1, left_on=\"股票代码\", right_on=\"股票代码\")\n",
    "df_merge"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 重新对列排序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['股票代码',\n",
       " '股票名称',\n",
       " '行业',\n",
       " '天数',\n",
       " '正负',\n",
       " '看好',\n",
       " '出手',\n",
       " '高数',\n",
       " '实际2',\n",
       " '结果',\n",
       " '20210210',\n",
       " '20210209',\n",
       " '20210208',\n",
       " '20210205',\n",
       " '20210204',\n",
       " '20210203',\n",
       " '20210202',\n",
       " '20210201',\n",
       " '20210129',\n",
       " '20210128',\n",
       " '20210127',\n",
       " '20210126',\n",
       " '20210125',\n",
       " '20210122',\n",
       " '20210121',\n",
       " '20210120',\n",
       " '20210119',\n",
       " '20210118',\n",
       " '20210115',\n",
       " '20210114']"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "columns = list(df_merge.columns)\n",
    "# 就是把list重新变成最终的模样\n",
    "columns.remove(\"高数\")\n",
    "columns.remove(\"实际2\")\n",
    "columns.insert(columns.index(\"结果\"), \"高数\")\n",
    "columns.insert(columns.index(\"结果\"), \"实际2\")\n",
    "columns"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 筛选列、转置数据、输出结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_result = df_merge[columns].transpose()\n",
    "df_result.to_excel(\"程序的结果.xlsx\", header=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
